package com.mmall.dao;

import com.mmall.pojo.User;
import org.apache.ibatis.annotations.Param;

public interface UserMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(User record);

    int insertSelective(User record);

    User selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(User record);

    int updateByPrimaryKey(User record);

    //从service跳转过来到此处的dao，接下来跳转到mappers中设计数据库查询用户的sql
    int checkUsername(String username);

    //验证改邮箱是否已经被使用了，是的话不能再用于注册
    int checkEmail(String email);

    //mybatis传递多个参数时，需要使用param注解
    User selectLogin(@Param("username")String username,String password);

    //查询用户的忘记密码问题
    String selectQuestionByUsername(String username);

    // 查询答案是否正确
    int checkAnswer(@Param("username")String username,@Param("question")String question,@Param("answer")String answer);

    //查询更改密码是否成功
    int updatePasswordByUsername(@Param("username")String username,@Param("passwordNew")String passwordNew);

    //校验密码是否属于该用户
    int checkPassword(@Param("password")String password,@Param("userId")Integer userId);

    //校验当前这个email是否是 本用户的
    int checkEmailByUserId(@Param("email")String email,@Param("userId")Integer userId);
}